#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>

int cmp(int* a, int* b)
{
    return *a - *b;
}
int* findErrorNums(int* nums, int numsSize, int* returnSize)
{
    *returnSize = 2;
    int* arr = (int*)malloc(2 * sizeof(int));
    qsort(nums, numsSize, sizeof(int), cmp);
    int i = 1;
    if (nums[0] != 1)
    {
        for (i = 1; i < numsSize; i++)
            if (nums[i - 1] == nums[i])
                break;
        arr[0] = nums[i];
        arr[1] = 1;
        return arr;
    }
    if (nums[numsSize - 1] != numsSize)
    {
        for (i = 1; i < numsSize; i++)
            if (nums[i - 1] == nums[i])
                break;
        arr[0] = nums[i];
        arr[1] = numsSize;
        return arr;
    }
    for (i = 1; i < numsSize; i++)
    {
        if (nums[i] == nums[i - 1])
        {
            arr[0] = nums[i];
        }
        if (nums[i] - nums[i - 1] > 1)
            arr[1] = nums[i - 1] + 1;
    }
    return arr;
}

int main()
{
    int num[] = { 1,2,2,4 };
    int n = 4;
    int b, * p = &b;
    int* s = NULL;
    s = findErrorNums(num, n, p);
    free(s);
}